<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript" src="/lookdom/js/jquery-1.8.0.js" charset="UTF-8"></script>
</head>
<body>
<input type="button" onclick="goIndex();" value="인덱스페이지"> <br><br>
	업무내용 확인
	<div id="bizListDiv"></div> <br><br>
	<div id="bizDetailDiv"></div>
</body>

<script type="text/javascript">

var biz = "";
var content = "";

	$.ajax({
		type	: "POST",
		url		: "/lookdom/getBizList.do",
		dataType: "json",
		data	: "",
		success	: function(data) {
			biz = data.bizList;
			//console.log(biz);
			
			content += "<table border='1'>";
			
			content += "<tr>";
			content += "<td>사업코드</td>";
			content += "<td>그룹코드</td>";
			content += "<td>사업명</td>";
			content += "<td>사업내용</td>";
			content += "<td>등록일자</td>";
			content += "<td>수정일자</td>";
			content += "</tr>";
			
			for(var i = 0; i < biz.length; i++){
				//console.log(biz[i].bizcd);
				
				content += "<tr>";
				content += "<td id=" + biz[i].bizcd;
				content += " onclick='goDetail(this);' style='border-bottom: 3px solid blue'>"; 
				content += biz[i].bizcd + "</td>";
				content += "<td>" + biz[i].bizcont + "</td>";
				content += "<td>" + biz[i].bizname + "</td>";
				content += "<td>" + biz[i].groupcd + "</td>";
				content += "<td>" + biz[i].stdate + "</td>";
				content += "<td>" + biz[i].modate + "</td>";
				content += "</tr>";
			}
			content += "</table>";
			$("#bizListDiv").html(content);
		},
        error: function(xhr, status, error) {
       	 alert('error-'+error); 
        }
	});
	
	function goDetail(item) {
		var bizcd = item.id;
		var bizDetail;
		var content = "";
		content += "<table border='1'>";
		content += "<td>사업코드</td>";
		content += "<td>그룹코드</td>";
		content += "<td>사업주제코드</td>";
		
		$.ajax({
			type	: "POST",
			url		: "/lookdom/getBizDetail.do?" + "bizcd=" + bizcd,
			dataType: "json",
			data	: "",
			success	: function(data) {
				console.log(data);
				bizDetail = data.bizDetail;
				console.log(bizDetail);
				
				
				
					//console.log(biz[i].bizcd);
					content += "<tr>";
					content += "<td>" + bizDetail.bizcd + "</td>";
					content += "<td>" + bizDetail.groupcd + "</td>";
					content += "<td>" + bizDetail.subjectcd + "</td>";
					content += "</tr>";
				content += "</table>";
				$("#bizDetailDiv").html(content);

			},
	        error: function(xhr, status, error) {
	       	 alert('error-'+error); 
	        }
		});
	}
	
	function goIndex() {
		var url = "/lookdom/index.do";
		$(location).attr('href',url); 
	}
</script>

</html>






